package com.gs.wzweather.test.convertword;

import java.io.*;
import java.util.concurrent.TimeUnit;

import com.gs.wzweather.utils.Constant;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.apache.commons.io.monitor.FileAlterationObserver;

/**
 * Created with IntelliJ IDEA.
 * User: Legolas
 * Date: 2017/10/25 0025
 */
public class WordToPdf {

    public static void main(String[] args) throws Exception {
        // 监控目录
        String rootDir = Constant.WordPath.THREEMONTHLY_FORCAST_PATH;
        // 轮询间隔 5 秒
        long interval = TimeUnit.SECONDS.toMillis(5);
        //
        FileAlterationObserver observer = new FileAlterationObserver(
                rootDir,
                (File pathName) -> (!pathName.getName().startsWith("`$") && pathName.getName().endsWith(".docx") || pathName.getName().endsWith(".doc")));
        observer.addListener(new MyFileListener(rootDir));
        FileAlterationMonitor monitor = new FileAlterationMonitor(interval, observer);
        // 开始监控
        monitor.start();
    }
}


